package com.school.test.search.function.base.controller;

import com.jfinal.core.Controller;
import com.school.test.search.function.assist.IndexAssist;
import com.school.test.search.function.datamodel.TestModel;

/**
 * @author 马洁
 * @date 2019/12/25 - 8:47
 */
public class BaseTeaAndStuController extends Controller {

    /**
     * 获取字符串并且去掉两边的空格
     * @param key 键
     * @return 获取后的值
     */
    protected String getTrim(String key) {
        return get(key).trim();
    }

    protected void setTestListInfo(final TestModel testListModel) {
        set("testList", testListModel.getTestList())
                .set("count", testListModel.getUntestedCount());

        setSemester();
    }

    protected void setSemester() {
        set("semester", IndexAssist.getSemester());
    }

    /**
     * 跳转回搜索页面
     */
    public void toSearch() {
        setSemester();
        render("search.html");
    }
}
